package com.gao.list;

import com.gao.domain.Student;

import java.util.ArrayList;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class ArrayListTest2 {
    /*
            需求：创建3个学生对象的集合，存储并使用控制台遍历该集合
     */
    public static void main(String[] args) {
        Student stu1 =new Student("张三",13);
        Student stu2 =new Student("李四",50);
        Student stu3 =new Student("王五",19);
        ArrayList<Student> list = new ArrayList<>();
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);
            System.out.println(student.getName()+"-----"+student.getAge());
        }
    }
}
